﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>title</title>
    <meta content="$homeContent.getURI('favicon.ico')" itemprop="image">
    <link rel="shortcut icon" href="$homeContent.getURI('favicon.ico')" type="image/x-icon"/>
    <link href="/assets/style.css" rel="stylesheet" type="text/css" /> 
    <link href="/assets/wallpaper.css" rel="stylesheet" type="text/css" /> 
    <link href="/assets/miniui/portal/portal.css" rel="stylesheet" type="text/css" />  
            
    <script src="/assets/miniui/boot.js" type="text/javascript"></script>
    <link href="/assets/miniui/miniui/themes/blue/skin.css" rel="stylesheet" type="text/css" />  
           
    <script src="/assets/echarts-2.2.1/build/dist/echarts-all.js" type="text/javascript"></script>
            
    <script src="/assets/js/util/util.js" type="text/javascript"></script>
    <script src="/assets/jcookie/jquery.cookie.js" type="text/javascript"></script>
    <script src="/assets/miniui/portal/Portal.js" type="text/javascript"></script>
    <script src="/assets/zdialog/zDialog.js" type="text/javascript"></script>
    <script src="/assets/zdialog/zDrag.js" type="text/javascript"></script>





@*    <script src="$adminContent.getURI('assets/swfupload/swfupload.js')" type="text/javascript"></script>
    <script src="$adminContent.getURI('assets/Plupload/demo/js/plupload/plupload.full.min.js')"></script>
    <script src="$adminContent.getURI('assets/Plupload/demo/js/qiniu.js')"></script>*@
    <link href="/assets/xtjm.css" rel="stylesheet" type="text/css" />
   
    <style>
        .my-mini-tree .mini-tree-icon {
            background-color: rgba(140, 178, 226, 0);
        }
    </style>

</head>

<body>
 <div class="mini-toolbar" style="border-bottom:0;">
        <table style="width:100%;">
            <tr>
            <td style="width:100%;">
                <a class="mini-button" iconCls="icon-add"   onclick="add()">新增</a>
                <a class="mini-button" iconCls="icon-edit"  onclick="edit()">编辑</a>
                <a class="mini-button" iconCls="icon-close" onclick="remove()">删除</a>
                <a class="mini-button" iconCls="icon-redo"  onclick="edit1()">重置密码</a>
            </td>
            <td style="white-space:nowrap;">
            	<span>用户名：</span>
            	<span><input id="key1" class="mini-textbox" emptyText="请输入用户名" style="width:150px;" onenter="onKeyEnter"/></span> 
                <span><a class="mini-button" iconCls="icon-search" onclick="search()">查询</a></span>
             </td>
            </tr>
        </table>
    </div>
    
    <div class="mini-fit" style="height:100px;">   
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" 
            url="/Sys/GetUser" idField="userId" pageSize="20" multiSelect="true">
            <div property="columns">
                <div type="checkcolumn" width="20"></div> 
                <div field="Username"  width="100" headerAlign="center" align="center" >用户名</div>
                <div field="Telephone"  width="100" headerAlign="center" align="center" >联系电话</div>
                <div field="Email"  width="200" headerAlign="center" align="center" >邮箱</div>
                <div field="IsEnable"  width="50" headerAlign="center" align="center" renderer="onEnableRenderer" >状态</div>
                <div field="CreateTime"  width="60" headerAlign="center" align="center"  dateFormat="yyyy-MM-dd " allowSort="true">创建日期</div>
                <div field="Remark"  width="200" headerAlign="center" align="left">备注</div>
                
            </div>
        </div> 
    </div>


</body>
<script type="text/javascript">
    mini.parse();
    var grid = mini.get("datagrid1");
    grid.sortBy("createTime", "desc");//默认排序
    grid.load();
   
    //新增加用户
    function add() {
        mini.open({
            url: "$adminContent/sys/addUser.htm",
            title: "新增用户", width: 600, height: 320,
            allowResize: false,       //允许尺寸调节
    		allowDrag: true,         //允许拖拽位置
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }
    //编辑用户
    function edit() {  
            var row = grid.getSelected();
            var rows = grid.getSelecteds();
            
            if(rows.length >1){
                mini.alert("请仅选中一条记录");
                return;
            }
            if (row) {
                mini.open({
                    url: "$adminContent/sys/addUser.htm",//同用增加页面
                    title: "编辑用户", width: 600, height: 320,
                    allowResize: false,       //允许尺寸调节
    				allowDrag: true,         //允许拖拽位置
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", userId: row.userId };
                        iframe.contentWindow.SetData(data);  
                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
                
            } else {
                mini.alert("请选中一条记录");
            } 
    }
    //编辑用户  密码
    function edit1() {  
            var row = grid.getSelected();
            var rows = grid.getSelecteds();
            
            if(rows.length >1){
                mini.alert("请仅选中一条记录");
                return;
            }
            if (row) {
                mini.open({
                    url: "$adminContent/sys/editpw.htm",//修改密码页面
                    title: "重置用户密码", width: 600, height: 320,
                    allowResize: false,       //允许尺寸调节
    				allowDrag: true,         //允许拖拽位置
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", userId: row.userId };
                        iframe.contentWindow.SetData(data);  
                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
                
            } else {
                mini.alert("请选中一条记录");
            } 
    }
    
    
    //删除用户记录
    function remove() {
        var rows = grid.getSelecteds();
        if (rows.length > 0) {
            if (mini.confirm("确定删除选中记录？","确认消息",deleteData)) {
                return false;
            }
        } else {
            mini.alert("请选中一条记录");
        }
    }
    function deleteData(action){

        if(action =='ok'){
        var rows = grid.getSelecteds();
        var ids = [];
        var names =[];
        for (var i = 0, l = rows.length; i < l; i++) {
                    var r = rows[i];
                    ids.push(r.userId);
                    names.push(r.username);
        }
        var id = ids.join(',');
        var name = names.join(',');
        grid.loading("操作中，请稍后......");
        jQuery.ajax({
            url: "$adminContent/adminScreen.do?action=SysUserAction&event_submit_do_delete=method",
            type: 'post',
            dataType: "text",
            data: { userIds: id,names:name},
            success: function (text) {
                if('more' == text){
                    mini.alert("当前用户不能删除自己");
                }
                grid.reload();
                
            }
        });         
        }   
    }

    //数据转换，字段是否有效，转换成对应的汉字信息
    function onEnableRenderer(e)
    {
        if (e.value == 0)
        {
            return "<span style='color:red;'>禁用</span>";
        }
        else
        {
        	return "<span style='color:green;'>启用</span>";
        }
    }
    function search() {
        var key1 = mini.get("key1").getValue();
        grid.load({ key1: key1 });
    }
    function onKeyEnter(e) {
        search();
    }
    </script>


</html>




